#include "client-handler.hh"

#include "server.hh"

ClientHandler::ClientHandler ()
  : cl_ ()
    //  , db_ (new Database ("content/playerdata.db"))
{
}

ClientHandler::~ClientHandler ()
{
  // save each client in a conf_file
}

void
ClientHandler::attach_server (Server* server)
{
  server_ = server;
}

void
ClientHandler::new_client (tcp::socket* sock)
{
  Client* client = 0;
  (void) sock;
  // char* buf = new char[1000];
  // boost::system::error_code error;
  // size_t len = 0;

  // lecture de la requete connexion

  // on construit la string du login et la string du password
  // std::string login = "";
  // std::string password = "";

  //  PlayerInfo* player = db_->find_player (login);

  // login valide && password valide
  // if (player && player->pass () == password)
  // {
  //   // on reponds good au client  
  //   // on l'ajoute dans la liste des clients
  // }
  // else
  // {
  //   boost::asio::write(*sock,
  // 		       boost::asio::buffer("Bad Login or Password"),
  // 		       ignored_error);
  // }

  server_->worldHandler ()->init_client (client);
}
